import { RiskControlScheme } from '@shared/interfaces/risk-control'
import { FormGroup, FormBuilder } from '@angular/forms'
import { RiskStoreService } from './risk-store.service'

export abstract class RiskControlNewBaseClass {
  riskControl: RiskControlScheme

  validateForm: FormGroup

  constructor(
    public fb: FormBuilder,
    public riskStore: RiskStoreService,
  ) {
    this.validateForm = this.fb.group({})
    this.initData()
  }

  initData(): void {
    this.riskStore
      .value$
      .subscribe(riskControl => this.riskControl = riskControl)
  }

  checkValid(): boolean {
    this.pushDataToStore()
    return true
  }

  abstract pushDataToStore(): void
}
